
public class Candidate implements Comparable
{
    // instance variables
    private int numOfVotes;
    private String name;
    private boolean male;
    
    /*** Constructor for objects of class Candidate*/
    public Candidate(String dasName, boolean m){
        name = dasName;
        male = m;
    } 
    
    public void addVote(){
        numOfVotes++;
    } 
    
    public boolean equals(Object o){
        Candidate o1 = (Candidate) o;
        return (o1.getName().equals(name));
    }
    
    public int compareTo(Object o){
        Candidate c = (Candidate) o;
        if(numOfVotes - c.getNumVotes() == 0){
            return 1;
        }
        return numOfVotes - c.getNumVotes();
    }
    
    public String getName(){
        return name;
    }
    
    public int getNumVotes(){
        return numOfVotes;
    }
    
    public boolean isMale(){
        return male;
    }
    
    public String toString(){
        return name + ": " + numOfVotes + " votes";
    }
}